package com.markerhub.mapper;

import com.markerhub.entity.TFacilityReqair;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.markerhub.povo.TFacilityReqairVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 刘佳明
 * @since 2021-12-30
 */
@Mapper
public interface TFacilityReqairMapper extends BaseMapper<TFacilityReqair> {

    @Select({"<script> SELECT a.* , c.project_name, c.projectid,d.number,b.username,\n" +
            "(CASE d.type  WHEN '0' THEN '滚筒洗衣机' WHEN '1' THEN '波轮洗衣机' WHEN '2' THEN '吹风机' WHEN '3' THEN '洗鞋机' ELSE '其他' END ) as types, " +
            "(CASE a.reqair_type  WHEN '0' THEN '进水异常' WHEN '1' THEN '出水异常' WHEN '2' THEN '支付成功不工作' WHEN '3' THEN '支付异常' WHEN '4' THEN '线路损坏' ELSE '其他' END ) as reqairTypes " +
            "FROM t_facility_reqair a , sys_user b, t_project_base c, t_facility_base d" +
            " where a.userobject = b.id and a.baseid = d.id and d.projectid = c.projectid\n" +
            " <when  test='number!=null  and number!=\"\"'>and d.number=#{number} </when>" +
            " <if test='projectid !=null and projectid!=\"\"'>and c.projectid=#{projectid}</if>" +
            " <if test='pages &gt;= 0 and limit &gt; 0'>limit #{pages}, #{limit}</if>"+
            "</script>"})
    List<TFacilityReqairVo> getReqairList(@Param("pages") Integer pages, @Param("limit")Integer limit, @Param("number")String number, @Param("projectid")String projectid);
}
